import { localSet, localGet, localRemove } from "@/common/utils/GlobalUtils";

const state = {
  xinZuFormYiZhan: "" || localGet("xinZuFormYiZhan"),
  xinZuFormWuYe: "" || localGet("xinZuFormWuYe"),
  xinZuForm: "" || localGet("xinZuForm"),
  tuiZuForm: "" || localGet("tuiZuForm"),
  propertyAcceptanceForm: "" || localGet("propertyAcceptanceForm"),
  supplementaryAgreementForm: "" || localGet("supplementaryAgreementForm"),
  assetInfoForm: "" || localGet("assetInfoForm"),
  housingResourcesForm: "" || localGet("housingResourcesForm"),
  customForm: "" || localGet("customForm"),
  propertyForm: "" || localGet("propertyForm"),
  xinZuSupplementaryAgreementForm:
    "" || localGet("xinZuSupplementaryAgreementForm"),
  budgetingForm: {} || localGet("budgetingForm"),
};

const mutations = {
  // 新租表单
  SET_XIN_ZU_FORM: (state, form) => {
    state.xinZuForm = form;
    localSet("xinZuForm", form);
  },
  // 新租物业表单
  SET_XIN_ZU_FORM_WUYE: (state, form) => {
    state.xinZuFormWuYe = form;
    localSet("xinZuFormWuYe", form);
  },
  // 新租驿站表单
  SET_XIN_ZU_FORM_YIZHAN: (state, form) => {
    state.xinZuFormYiZhan = form;
    localSet("xinZuFormYiZhan", form);
  },
  // 退租表单
  setTuiZuForm: (state, form) => {
    state.tuiZuForm = form;
    localSet("tuiZuForm", form);
  },
  // 物业验收单
  setPropertyAcceptanceForm: (state, form) => {
    state.propertyAcceptanceForm = form;
    localSet("propertyAcceptanceForm", form);
  },
  // 补充协议
  setSupplementaryAgreementForm: (state, form) => {
    state.supplementaryAgreementForm = form;
    localSet("supplementaryAgreementForm", form);
  },
  // 资产库信息
  setAssetInfoForm: (state, form) => {
    state.assetInfoForm = form;
    localSet("assetInfoForm", form);
  },
  // 房源库信息
  setHousingResourcesForm: (state, form) => {
    state.housingResourcesForm = form;
    localSet("housingResourcesForm", form);
  },
  // 客户库信息
  setCustomForm: (state, form) => {
    state.customForm = form;
    localSet("customForm", form);
  },
  // 物业库信息
  setPropertyForm: (state, form) => {
    state.propertyForm = form;
    localSet("propertyForm", form);
  },
  // 新租补充协议
  SET_XIN_ZU_SUPPLEMENTARY_AGREEMENT_FORM: (state, form) => {
    state.xinZuSupplementaryAgreementForm = form;
    localSet("xinZuSupplementaryAgreementForm", form);
  },
  RESET_XIN_ZU_FORM: (state) => {
    localRemove("xinZuForm");
    state.xinZuForm = "";
  },
  RESET__XIN_ZU_SUPPLEMENTARY_AGREEMENT_FORM: (state) => {
    localRemove("xinZuSupplementaryAgreementForm");
    state.xinZuSupplementaryAgreementForm = "";
  },
  set_budgetingForm: (state, form) => {
    state.budgetingForm = form;
    localSet("budgetingForm", form);
  },
};

export default {
  state,
  mutations,
};
